import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tasks")
public class TaskController {

    private final PhoneTaskService taskService;

    public TaskController(PhoneTaskService taskService) {
        this.taskService = taskService;
    }

    @PostMapping("/add")
    public void addTask(@RequestParam String phoneNumber, @RequestBody Runnable task) {
        taskService.addTask(phoneNumber, task);
    }

    @PostMapping("/urgent")
    public void addUrgentTask(@RequestParam String phoneNumber, @RequestBody Runnable task) {
        taskService.addUrgentTask(phoneNumber, task);
    }

    @PostMapping("/cancel")
    public void cancelTask(@RequestParam String phoneNumber, @RequestParam int taskId) {
        taskService.cancelTask(phoneNumber, taskId);
    }

    @PostMapping("/cancelAll")
    public void cancelAllTasks(@RequestParam String phoneNumber) {
        taskService.cancelAllTasks(phoneNumber);
    }
}
